import 'package:flutter/material.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MyApp2();
  }
}

class Demo1 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    var bar1 = PreferredSize(
      preferredSize: Size.fromHeight(kToolbarHeight),
      child: new Container(
        color: Colors.yellow,
        child: new SafeArea(
          child: Text("44"),
        ),
      ),
    );
    var bar2 = PreferredSize(
      preferredSize: Size.fromHeight(0),
      child: Container(),
    );
    return Scaffold(
      appBar: bar2,
      body: Column(
        children: <Widget>[
          Container(
            constraints: BoxConstraints.expand(
              height:
                  Theme.of(context).textTheme.display1.fontSize * 1.1 + 200.0,
            ),
            padding: const EdgeInsets.all(8.0),
            color: Colors.blue[600],
            alignment: Alignment.center,
            child: Text('Hello World',
                style: Theme.of(context)
                    .textTheme
                    .display1
                    .copyWith(color: Colors.white)),
            transform: Matrix4.rotationZ(0.1),
          ),
          Text("11")
        ],
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: NestedScrollView(
          headerSliverBuilder: _sliverBuilder,
          body: Center(
            child: Text('hahaha'),
          )),
    );
  }
}

List<Widget> _sliverBuilder(BuildContext context, bool innerBoxIsScrolled) {
  return <Widget>[
    SliverAppBar(
      centerTitle: true,
      //标题居中
      expandedHeight: 200.0,
      //展开高度200
      backgroundColor: Colors.tealAccent,
      floating: false,
      //不随着滑动隐藏标题
      pinned: false,
      //不固定在顶部
      flexibleSpace: FlexibleSpaceBar(
        centerTitle: true,
        background: Icon(Icons.add),
      ),
    )
  ];
}

class MyApp2 extends StatelessWidget {
  Column buildButtonColumn(IconData icon, String label) {
    Color color = Colors.red;

    return new Column(
//      mainAxisSize: MainAxisSize.min,
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        new Icon(icon, color: color),
        new Container(
          margin: const EdgeInsets.only(top: 8.0),
          child: new Text(
            label,
            style: new TextStyle(
              fontSize: 12.0,
              fontWeight: FontWeight.w400,
              color: color,
            ),
          ),
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    //...

    Widget buttonSection = new Container(
        child: Scaffold(
      appBar: AppBar(),
      body: Column(
        children: <Widget>[
          new Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              buildButtonColumn(Icons.call, 'CALL'),
              buildButtonColumn(Icons.near_me, 'ROUTE'),
              buildButtonColumn(Icons.share, 'SHARE'),
            ],
          ),
          new Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [
              buildButtonColumn(Icons.call, 'CALL'),
              buildButtonColumn(Icons.near_me, 'ROUTE'),
              buildButtonColumn(Icons.share, 'SHARE'),
            ],
          ),
          new Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              buildButtonColumn(Icons.call, 'CALL'),
              buildButtonColumn(Icons.near_me, 'ROUTE2'),
              buildButtonColumn(Icons.share, 'SHARE'),
            ],
          )
        ],
      ),
    ));
    return buttonSection;
  }
}
